package com.jiang.daily.Q2239;

/**
 * @author Jiang
 * @version 1.0
 * @date 2025/01/20 0:23
 */
class Solution {
    public int findClosestNumber(int[] nums) {
        int res = Integer.MAX_VALUE;
        for (int i = 0; i < nums.length; i++) {
            if (Math.abs(nums[i]) <= Math.abs(res)) {
                if (nums[i] < 0 && -nums[i] == Math.abs(res)) continue;
                res = nums[i];
            }
        }
        return res;
    }
}